/*
 * $Id: ActRunDetailsDAO.java,v 1.4 2009/07/10 14:50:16 navdeep_mahajan Exp $
 * 
 * Copyright (C) 2006 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.common.database.dao;

import java.util.Date;

import com.ge.healthcare.autosc.common.ASCUtil;
import com.ge.healthcare.autosc.common.database.pojo.ActRunDetails;
import com.ge.healthcare.autosc.common.util.TimeFormatStandard;

/**
 * @author 212042764
 * 
 */
public class ActRunDetailsDAO extends BaseDAO implements IRunDetailsDAO {
	/**
	 * Eclispe generated
	 */
	private static final long serialVersionUID = 1633590519826461265L;
	private static final String TABLE_NAME = "com.ge.healthcare.autosc.common.database.pojo.ActRunDetails";
	private static final String COL_PROCESS_NAME = "processName";

	/**
	 * For setting table name
	 */
	protected ActRunDetailsDAO() {
		super(TABLE_NAME);
	}

	/**
	 * Saves the processes last run details. Last Run time is set as now
	 * 
	 * @param processName
	 *            - Process name which ran
	 */
	public void saveRunDetails(String processName) {
		this.saveRunDetails(processName, TimeFormatStandard.getNowMillis());
	}

	/**
	 * Saves the processes last run details
	 * 
	 * @param processName
	 *            - Process name which ran
	 * @param runTime
	 *            - Last run time
	 */
	public void saveRunDetails(String processName, Date runTime) {
		ActRunDetails runDtails = new ActRunDetails(processName, runTime);
		save(runDtails);
	}

	/**
	 * Returns run details for the process
	 * 
	 * @param processName
	 *            - Process Name to lookup for
	 * @return - Run details
	 */
	public ActRunDetails getByProcessName(String processName) {
		Object runDetails = findObjectByID(COL_PROCESS_NAME, processName);
		if (ASCUtil.isNullOrEmptyObject(runDetails)) {
			return null;
		}
		return (ActRunDetails) runDetails;
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.BaseDAO#save(java.lang.Object)
	 */
	public void save(Object pojo) {
		super.save(pojo);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.IRequestTypeDAO#saveAlways(java.lang.Object)
	 */
	public void saveAlways(Object pojo) {
		super.save(pojo);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.BaseDAO#deleteByID(java.lang.Object)
	 */
	public void deleteByID(Object pojo) {
		super.deleteByID(pojo);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.BaseDAO#refresh(java.lang.Object)
	 */
	public void refresh(Object pojo) {
		super.refresh(pojo);
	}
}
